<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<head>
<link rel="stylesheet" type="text/css" href="/css/style_fx.css" />
    <title>发现-笔飞美术作品</title>
    <script type="text/javascript" src="/js/jquery-1.4.3.min.js"></script>
       <%@include file="../common/jspcommon.jsp"%>
       <%@include file="../common/css.jsp"%>
       <script type="text/javascript" src="js/jquery.validate.js"></script>
       <script src="/js/jquery.json-2.2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="box">
     <%@include file="../common/header.jsp" %>
    <div id="main_div">
        <div class="site_map"><a href="welcome.htm">首页</a> 》发现</div>
        
        <div class="main_div_left3">
            <div class="div_2">
                <div class="div_2_t"><span class="fl"><b>您购买的商品</b></span></div>
                <div class="div_2_c">
                    <div class="div_jxgw"></div>
                    <div class="div_cart">
                        <div class="div_cart_img"><a href="#"><img src="${artPic.imagePath }_100x100" alt="" /></a></div>
                        <div class="div_cart_info">
                            <div class="div_cart_info_t"><div class="fl"><b>${artPic.title}</b></div><div class="fr"> 
                            <b> <c:if test="${!empty artPic.priceLow }"><c:if test="${ artPic.priceLow >0 }"> RMB  ${artPic.priceLow } </c:if></c:if>
                    <c:if test="${empty artPic.priceLow || artPic.priceLow==0}">RMB  ${artPic.price}</c:if></b>　</div></div>
                            <table cellpadding="0" cellspacing="0" border="0" style="width:100%; margin-top:10px; float:left;">
                           
                            <tr>
                                <td style="width:50%" >适用空间：${artPic.groundName}</td>
                                <td>材质：${artPic.materialName}</td>
                            </tr>
                            <tr>
                                <td style="width:50%">尺寸：${artPic.artSizeName}</td>
                                <td>标签：${artPic.tagName}</td>
                            </tr>
                            <tr>
                                <td style="width:50%">分类：${artPic.artClassName}</td>
                                <td>建议用途：${artPic.useName}</td>
                            </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <div class="div_2 mt20">
            					
                <div class="div_2_t"><span class="fl"><b>收货地址</b></span><span class="style6 fr">* 为必选项</span>
                </div>
                				<div style="text-align: center;">
	                				<c:if test="${!empty addressList }">
		                                	<c:forEach items="${addressList}" var="list" varStatus="vs">
		                                			<br/>
		                                			<br/>
		                                			<br/>
		                                			<br/>
			                                    	<input id="payFrom${vs.count }" type="radio" name="payFrom" value="${list.id}" />&nbsp;&nbsp;&nbsp;
													<label for="payFrom${vs.count }">
													${list.province}${list.city}${list.county}${list.address}(${list.addressName})收${list.phone}
													</label>
		                               		 </c:forEach>
	                                	</c:if>
                                </div>
                <div class="div_2_c">
                    <form  id="newAddressForm"  method="post">
                                  <table cellpadding="10" cellspacing="0" class="member_table3" >
                                        <tr>
                                            <td colspan="2" class="td44"> <span class="style5"></span>  <span class="style6 fr"> 新增收货地址</span>  </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*配送区域：</td>
                                            <td align="left">
		                                        <select name="show_data" tabindex="10" id="province"> </select>
		                                        <select name="show_data" tabindex="10" id="city"> </select>
		                                        <select name="show_data" tabindex="10" id="county"> </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="width:110px; text-align:right;">*收货人姓名：</td>
                                            <td align="left"><input type="text" class="input1" name="addressName" id="addressName" /></td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*电子邮箱地址：</td>
                                            <td align="left"><input type="text" class="input1" name="email" id="email"/></td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*详细地址：</td>
                                            <td align="left"><input type="text" class="input1" name="address" id="address"/></td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*邮政编码：</td>
                                            <td align="left"><input type="text" class="input1" name="zipcode" id="zipcode"/></td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*手机：</td>
                                            <td align="left"><input type="text" class="input1" name="phone" id="phone"/></td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*电话：</td>
                                            <td align="left"><input type="text" class="input1" name="telphone" id="telphone"/></td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*标志建筑：</td>
                                            <td align="left"><input type="text" class="input1" name="remark" id="remark"/></td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:right;">*最佳送货时间：</td>
                                            <td align="left"><input type="text" class="input1" name="goodTime" id="goodTime"/></td>
                                        </tr>
                                        <tr>
                                            <td></td>
                                            <td align="right"><input type="submit" name="Submit" value="" class="submit btn_special btn_xzshdz"/></td>
                                        </tr>
                               		 </table>
                               </form>
                </div>
            </div>
        </div>
        
        <div class="main_div_right3">
            <div class="div_3">
                <div class="div_3_t"><span class="fl"><b>摘要</b></span></div>
                <div class="div_3_c">
                    <p>合计</p>
                    <p><b>
                    <c:if test="${!empty artPic.priceLow }"><c:if test="${ artPic.priceLow >0 }"> RMB  ${artPic.priceLow } </c:if></c:if>
                    <c:if test="${empty artPic.priceLow || artPic.priceLow==0}">RMB  ${artPic.price}</c:if>
                    </b></p>
                    <p class="style3">免费送货</p>
                    <p class="mt5"><a href="#" onclick="addOrder()"><img src="../images/btn_ljdg.jpg" alt="" /></a></p>
                </div>
            </div>
        </div>
        <%@include file="../common/footer.jsp" %>	
    </div>
</div>

<script type="text/javascript">
initProvince('province', 'city','county');
	$("#newAddressForm").validate(
		{
			rules : {
				addressName : {
					required : true,
					minlength : 2,
					maxlength : 20
				},
				email : {
					required : true,
					minlength : 2,
					maxlength : 20
				} ,
				address : {
					required : true,
					minlength : 2,
					maxlength : 20
				} ,
				zipcode : {
					required : true,
					minlength : 2,
					maxlength : 20
				} ,
				phone : {
					required : true,
					minlength : 2,
					maxlength : 20
				} ,
				telphone : {
					required : true,
					minlength : 2,
					maxlength : 20
				} ,
				remark : {
					required : true,
					minlength : 2,
					maxlength : 20
				} ,
				goodTime : {
					required : true,
					minlength : 2,
					maxlength : 20
				}
			},
			messages : {
				addressName : {
					required : "请填写开户人姓名",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				},
				email:{
					required : "请填写邮箱",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				},
				address:{
					required : "请填写地址",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				},
				zipcode:{
					required : "请填写邮编",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				},
				phone:{
					required : "请填写手机",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				},
				telphone:{
					required : "请填写电话",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				},
				remark:{
					required : "请填写编制建筑",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				},
				goodTime:{
					required : "请填写最佳送货时间",
					minlength : "长度为2～20位",
					maxlength : "长度为2～20位"
				}
			},
			submitHandler : function() {
				$.post("saveAddress.htm", {
					provinceCode : $("#province").val(),
					cityCode : $("#city").val(),
					province : $("#province").find("option:selected").text(),
					city : $("#city").find("option:selected").text(),
					countyCode : $("#county").val(),
					county : $("#county").find("option:selected").text(),
					addressName : $("#addressName").val(),
					email : $("#email").val(),
					address : $("#address").val(),
					zipcode : $("#zipcode").val(),
					phone : $("#phone").val(),
					telphone : $("#telphone").val(),
					remark : $("#remark").val(),
					goodTime : $("#goodTime").val()
					}, function(data) {
						if (data == 'success') {
							window.location.href="/buyArt.htm?id=${id}"
						} else{
							alert("添加失败");
						}
					});
			}
		});
	
			function addOrder(){
				var addId=$("input[name='payFrom']:checked").val();
				if(addId !=null){
					$.post("addFindOrder.htm", {
						picId:${id},
						address : addId
						}, function(isJoin) {
								var res = $.evalJSON(isJoin);
								if(res.date){
									window.location.href="payArt.htm?orderId="+res.orderId;
								}else{
									alert("不好意思，没有库存了。。");
								}
								
						});
				}else{
					alert("请选择收货地址。")
				}
			}
	</script>

</body>
</html>
